//
// Created by antler on 2018/12/19.
//

#ifndef LUA_UI_H
#define LUA_UI_H

#include <string>
#include "UIContext.h"

#define CLASSNAME_UI "UI"
#define USERTYPE_UI "UI"

#define CLASSNAME_UI_TYPE "TYPE"
#define USERTYPE_UI_TYPE "TYPE"

#define CLASSNAME_UI_ACTION "ACTION"
#define USERTYPE_UI_ACTION "ACTION"

#define CLASSNAME_UI_PSEUDO "PSEUDO"
#define USERTYPE_UI_PSEUDO "PSEUDO"

#define CLASSNAME_UI_TOAST "TOAST"
#define USERTYPE_UI_TOAST "TOAST"


class UI {
public:
    class TYPE {
    public:
        enum {
            UNKNOWN = -1,
            CONTAINER = 0,
            DIV = 1,
            TEXT = 2,
            IMAGE = 3,
            SCROLLER = 4,
            LIST = 5,
            SWITCH = 10,
            INPUT = 11,
            TEXTAREA = 12,
            VIDEO = 13,
            INDICATOR = 14,
            WEB = 17,
            LOADING = 18,
        };
    };

    class ACTION {
    public:
        enum {
            APPEAR = 0,
            DISAPPER = 1,
            CLICK = 2,
            LONG_PRESS = 3,
            SWIPE = 4,
        };
    };

    class PSEUDO {
    public:
        static const char *ACTIVE;
        static const char *FOCUS;
        static const char *ENABLED;
        static const char *DISABLED;
    };

    class TOAST {
    public:
        enum {
            LENGTH_SHORT = 0,
            LENGTH_LONG = 1,
        };
    };

public:
    static UI *getInstance();

    static void releaseInstance();

    UI();

    ~UI();

    // Toast提示
    void toast(const std::string &msg, int length);

    // 构建UI实例
    UIContext *createContext(const std::string &layout, const std::string &style);

    void registerUI(const std::string &name, const std::string &layout);

protected:
    static UI *g_pUI;
};


#endif //LUA_UI_H
